package com.xr.system;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.utils.variant.VariantSet;
import com.bstek.dorado.common.*;

/**
 * sessionManage_datasetSessionListener
 */
public class sessionManage_datasetSessionListener extends AbstractDatasetListener {
  public void afterLoadData(Dataset dataset)
     throws Exception {
	  DoradoContext context = DoradoContext.getContext();
	  HashMap sessions = (HashMap) context.getAttribute(context.APPLICATION,"Sessions");
	  //Iterator it=sessions.entrySet().iterator();
	  if (sessions==null){
		  return ;
	  }
	  //Thread.sleep(10000);
	  Iterator it=sessions.keySet().iterator();
	  while(it.hasNext()){
		  Object key=it.next();
		  User u=(User)sessions.get(key);
		 // context.
	      //System.out.println("==="+key+"===="+u.getRealName());
	      dataset.insertRecord();
	      dataset.setValue("sessionId", key);
	      dataset.setValue("userId", u.getUserId());
	      dataset.setValue("realName", u.getEmployeeName());
	      dataset.setValue("deptName", u.getDeptName());
	   
	  } 
 
  }

}
